﻿using System;
using System.Collections.Generic;
using System.Web;
using WinnerCMS.Common;
using System.IO;

namespace WinnerCMS.Install
{
    public class InitData
    {

        public void BuildObject()
        {

            string sql;
            string sqlPath = HttpContext.Current.Server.MapPath(@"~\Install\脚本1.sql");
            if (File.Exists(sqlPath))
            {
                sql = File.ReadAllText(sqlPath);
            }
            else
            {
                sql = ResHelper.GetResourceContents("WinnerCMS.Install", "WinnerCMS.Install.脚本1.sql");
            }


            List<string> list = SQLBaseV2.SqlText2SqlList(sql);
            SQLBaseV2.ExecuteNonQuery(list);
        }

        public void InsertMustData( )
        {
            string sql;
            string sqlPath = HttpContext.Current.Server.MapPath(@"~\Install\脚本2.sql");
            if (File.Exists(sqlPath))
            {
                sql = File.ReadAllText(sqlPath);
            }
            else
            {
                sql = ResHelper.GetResourceContents("WinnerCMS.Install", "WinnerCMS.Install.脚本2.sql");
            }


            SQLBaseV2.ExecuteNonQuery(sql.Trim());
           
        }

    }
}
